#include<stdio.h>
#include<string.h>
#include<iostream>
#include"sqlite3.h"
#include"sqlQuery.h"

using namespace  std;

int main()
{
    /*
    sqlite3 *pdb=NULL;
    string sql="create table t1(id int ,name text)";
    int re=sqlite3_open("t.db",&pdb);
    if(re!=SQLITE_OK){
	printf("open error\n");
	printf("ok=%d",SQLITE_OK);
    }
    
    re=sqlite3_exec(pdb,"create table user(id int,name text)",NULL,NULL,NULL);
    if(re!=SQLITE_OK){
	printf("creat error\n");
	printf("ok=%d\n",SQLITE_OK);
	sqlite3_exec(pdb,sql.c_str(),NULL,NULL,NULL);
    }
    sql="insert into t1 values(1,'man')";
    sqlite3_exec(pdb,sql.c_str(),NULL,NULL,NULL);
   */
//    char **tb;
// /   int r,c;
//    sqlite3_get_table(pdb,sql.c_str(),&tb,&r,&c,NULL);
 //   printf("c=%d,r=%d\n",c,r);
//    for(int i=0;i<r;++i){
//	for(int j=0;j<c;++j){
//	    printf("%s  \n",tb[i*c+j]);
//	}
//  }
//    sqlite3_free_table(tb);
//    sqlite3_close(pdb);

    int n=1;
    while(n--){
    SqlQuery Q;
    string sql="select id,name,status from home where status=0";
    cout<<"-------------------------"<<endl;
    if(!Q.open("food.db"))cout<<"class open error!"<<endl;;
   // if(!Q.exec(sql))cout<<"exec error"<<endl;
    SqlResult R=Q.Query(sql);
    //Q->table.show();
//    R.show();
    R.GetResult();

    sql="update desk set sum=sum+1 where id=1 and status=1 and tablenum=1";
    if(!Q.exec(sql))cout<<"exec error"<<endl;
    else cout<<"okok"<<endl;
    if(!Q.close())cout<<"class close error!"<<endl;
    }


    return 0;
}
